package com.kuroneko.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.kuroneko.excel.entity.User;
import com.kuroneko.excel.listener.NoModelDataListener;

import java.util.List;
import java.util.Objects;

public class Do {

    private static final String TBL = "tbl";

    public static void main(String[] args) {
        String fileName = Objects.requireNonNull(Do.class.getClassLoader().getResource("1.xlsx")).getFile();
        System.out.println(fileName);

//        List<ReadSheet> sheets = EasyExcel.read(file).build().excelExecutor().sheetList();
//        for (ReadSheet sheet : sheets) {
//            if (sheet.getSheetName().startsWith(TBL)) {
//                EasyExcel.read(file, User.class, new PageReadListener<User>(users -> {
//                    for (User user : users) {
//                        System.out.println(user);
//                    }
//                })).sheet().headRowNumber(4).doRead();
//            }
//        }

        List<ReadSheet> sheets = EasyExcel.read(fileName).build().excelExecutor().sheetList();
        for (ReadSheet sheet : sheets) {
            String sheetName = sheet.getSheetName();
            if (sheetName.startsWith(TBL)) {

                EasyExcel.read(fileName, new NoModelDataListener<User>(sheetName)).sheet().headRowNumber(4).doRead();
            }
        }

        log.info("结束！");

    }
}
